class HttpConnection : public std::enable_shared_from_this<HttpConnection>
{
	::boost::asio::io_context& _ioc;
	::boost::beast::tcp_stream _stream;
	::boost::asio::steady_timer _timer;
	::boost::beast::flat_buffer _buffer;
	::boost::beast::http::request_parser<::boost::beast::http::dynamic_body> _parser;
	::boost::beast::http::response<::boost::beast::http::string_body> _res;

	bool _close = false;
	bool _chunkSending = false;
	bool _chunkHeader = false;
	bool _chunkFinish = false;
	std::list<std::string> _chunkBody;

public:
	HttpConnection(::boost::asio::io_context& ioc, ::boost::asio::ip::tcp::socket socket);
	void start();

	void doPost();
	void doPostLogin();
	void doPostChat();
	void doPostChatList();
	void doPostChatCreate();

private:
	void readRequest();
	void processRequest();
	void sendResponse();
	void sendResponse(char ec, const char* what);
	void sendChunk();

	void shutdown(::boost::beast::error_code ec);
	void handleError(::boost::beast::error_code ec, const char* what);
	char hex2ch(char hex);
};

